Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | "use client"; import { useEffect } from "react"; import { useParams, useRouter, useSearchParams } from "next/navigation"; /** * Referral redirect page * Clean URL: /ref/[code]?redirect=/path * Redirects via affiliate tracking API */ export default function ReferralPage() { const params = useParams(); const router = useRouter(); const searchParams = useSearchParams(); useEffect(() => { const code = params.code as string; const redirect = searchParams.get("redirect") || "/"; // Redirect to tracking API which will set cookie and redirect window.location.href = `/api/affiliates/${code}/track?redirect=${encodeURIComponent(redirect)}`; }, [params.code, router, searchParams]); return ( <div className="min-h-screen flex items-center justify-center bg-gray-100 dark:bg-gray-900"> <div className="text-center"> <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 dark:border-blue-400 mx-auto mb-4" /> <p className="text-gray-600 dark:text-gray-400">Redirecting...</p> </div> </div> ); } |